<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
class HomeBlogController extends Controller
{
   public function index(){
        $article=DB::table('article')
        ->join('user','article.uid','=','user.id')->where('trash','0')
        ->select('article.*','user.username')->orderBy('time','desc')
        ->get();
        
        foreach($article as $k=>$v){
            $article[$k]->num=DB::table('blogreply')->where('pid','=',$v->id)->count();
        }
        // dd($article);
        return view('home.blog.blog',['article'=>$article]);
   }
}
